<?php

namespace app\service\Web;

use app\model\Industry;

class IndustryService
{
    public static function getAll(array $where = [])
    {
        $industry = new Industry();

        if (!empty($where['is_show'])) {
            $industry = $industry->where('is_show', $where['is_show']);
        }
        if (!empty($where['lang'])) {
            $industry = $industry->where('lang', $where['lang']);
        }
        if (!empty($where['name'])) {
            $industry = $industry->where('name', $where['name']);
        }
        if (!empty($where['parent_id'])) {
            $industry = $industry->where('parent_id', $where['parent_id']);
        }
        if (!empty($where['platform'])) {
            $industry = $industry->where('platform', $where['platform']);
        }
        if (!empty($where['sort'])) {
            $industry = $industry->where('sort', $where['sort']);
        }
        return $industry->orderBy('sort', 'asc')->orderBy('id', 'desc')->get()->toArray();
    }
}
